#define DEBUG
#include <cstdio>
#include <cstring>

using namespace std;

const int maxn=10000;

int debugcnt=0;

int max(int a, int b) {
  return a>b ? a : b;
}

void addUp(int n, int a[]) {
  for (int i=1; i<=n; i++) a[i] += a[i-1];
}

int cmp(int n, int len, int a[], int x, int y) {
  return !(a[x]==a[y] && (x+len<=n ? (y+len<=n && a[x+len]==a[y+len]) : y+len>n));
}

void getSa(int n, char *s, int sa[], int rank[]) {
  static int cnt[maxn+1], tmp[maxn+1];
  cnt[0] = 0;
  for (int i=1; i<=n; i++) {
    rank[i] = s[i]-'a'+1;
    cnt[rank[i]]++;
  }
  addUp(26, cnt);
  for (int i=1; i<=n; i++) sa[cnt[rank[i]]--] = i;

  for (int len=1; len<n; len<<=1) {
    memset(cnt, 0, sizeof cnt);
    for (int i=1; i<=n; i++) cnt[rank[i]]++;
    addUp(rank[sa[n]], cnt);
    for (int i=n; i>0; i--) if (sa[i]>len) tmp[cnt[rank[sa[i]-len]]--] = sa[i]-len;
    for (int i=n; i>n-len; i--) tmp[cnt[rank[i]]--] = i;
    for (int i=1; i<=n; i++) sa[i] = tmp[i], tmp[i] = rank[i];
    for (int i=1; i<=n; i++) rank[sa[i]] = rank[sa[i-1]]+cmp(n, len, tmp, sa[i-1], sa[i]);
  }
}

void getHeight(int n, char *s, int sa[], int rank[], int h[]) {
  for (int i=1; i<=n; i++) {
    int x=rank[i], t=sa[x-1];
    if (x==1) {
      h[x] = 0;
    } else {
      for (h[x] = max(h[rank[i-1]]-1, 0); i+h[x]<=n && t+h[x]<=n && s[i+h[x]]==s[t+h[x]]; h[x]++);
    }
  }
}

int main() {
#ifdef DEBUG
  freopen("src.in", "r", stdin);
  freopen("src.out", "w", stdout);
#endif

  static int sa[maxn+1], rank[maxn+1], h[maxn+1];
  static char s[maxn+2];
  scanf("%s", s+1);
  int len=strlen(s+1);
  getSa(len, s, sa, rank);
  getHeight(len, s, sa, rank, h);

  static int block[maxn+1], bp[maxn+1], last[maxn+1], bk[maxn+1];
  int ansl=0, ansk=0, ansp=0;
  for (int nowl=1; nowl<=len/2; nowl++) {
    block[sa[1]] = 1, bp[1] = 1, bk[1] = 0, last[1] = 0;
    for (int i=2; i<=len; i++) {
      if (h[i]>=nowl) {
        block[sa[i]] = block[sa[i-1]];
      } else {
        block[sa[i]] = block[sa[i-1]]+1;
        int t=block[sa[i]];
        bp[t] = sa[i], last[t] = bk[t] = 0;
      }
      debugcnt++;
    }

    for (int i=1; i<=len-nowl+1; i++) {
      if (last[block[i]]<i) {
        bk[block[i]]++;
        last[block[i]] = i+nowl-1;
      }
      debugcnt++;
    }

    for (int i=1; i<=block[sa[len]]; i++) {
      if (bk[i]>1) {
        if (bk[i]*nowl>ansk*ansl || (bk[i]*nowl==ansk*ansl && rank[bp[i]]<rank[ansp])) {
          ansp = bp[i], ansl = nowl, ansk=bk[i];
        }
      }
      debugcnt++;
    }
  }

  if (ansp) {
    printf("%d\n", ansl*ansk);
    for (int i=1; i<=ansl; i++) {
      printf("%c", s[ansp+i-1]);
    }
  } else {
    printf("-1");
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
